#!/bin/bash

# Copyright 2021 Jeff Cliff
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (ie at COPYING.GPL)
#  If not, see <https://www.gnu.org/licenses/>.

MEMEDIR=/mnt/disk5/meme


STERM='"'"${@:1}"'"'
TMPFILE=`mktemp`
echo grep -H -i $STERM $MEMEDIR/20/0/2/booksread >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/0/3/booksread.txt >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/0/5/booksread >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/0/6/books-read-2006 >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/0/7/books-read-2007 >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/0/8/booksread >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/0/9/booksread >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/1/0/booksread >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/1/1/booksread >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/1/2/booksread >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/1/3/alreadyread.txt >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/1/4/alreadyread.txt >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/1/5/alreadyread.txt >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/1/6/alreadyread.txt >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/1/7/alreadyread.txt >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/1/8/alreadyread.txt >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/1/9/alreadyread.txt >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/2/0/alreadyread.txt >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/20/2/1/alreadyread.txt >> $TMPFILE
echo grep -H -i $STERM $MEMEDIR/1990s -r >> $TMPFILE

chmod 755 $TMPFILE
$TMPFILE | awk -F'/' '{print $5 $6 $7}'
# echo $TMPFILE
# rm $TMPFILE

